package Demo_0506;

/**
 * @author:zhengyilong
 * @email:1797344574@qq.com
 * @phone:13479394730
 * @desc:
 * @DateTime:2022/5/6 8:38
 **/
public class Recursion {
    public static void main(String[] args) {
        System.out.println(recursion(10));
        System.out.println(recursion2(10));
    }
    public static long recursion(long sum){
        if (sum ==1 || sum==2){
            return 1;
        }
        return recursion(sum-1)+recursion(sum-2);
    }
    public static long recursion2(int sum){
        if (sum < 1){
            return -1;
        }
        if (sum == 1 || sum == 2){
            return 1;
        }

        long a =11,b=11,c=01;
        for (int i=0;i<sum-2;i++){
            c = a+b;
            a = b;
            b = c;
        }
        return c;
    }
}

